<template>
	<view>
		<view class="uesr-info">
			<image :src="portrait" class="wx-portrait"></image>
			<view v-if="!nickname" class="wx-nickname" @click="login()">点击登录</view>
			<view v-if="nickname" class="wx-nickname">{{ nickname }}</view>
		</view>
		<!-- <view class="card-item" @click="test()">我的点赞</view> -->
		<view class="cu-list menu card-menu margin-top-xl margin-bottom-xl shadow-lg">
			<view class="cu-item arrow" @click="toOrder()" v-if="isCanPay == 1">
				<view class="content" hover-class="none">
					<text class="icon-more text-green"></text>
					<text class="text-grey">我的订单</text>
				</view>
			</view>
			<view class="cu-item arrow">
				<view class='icon-likefill text-red'>
					<!-- <image src="../../static/inages/wenti.png" class="icon"></image> -->
				</view>
				<button class="cu-btn content" open-type='feedback'>
					<text class="icon-servicefill text-cyan"></text>
					<text class="text-grey">问题反馈</text>
				</button>
			</view>

			<view class="cu-item arrow">
				<view class='icon-likefill text-red'>
					<!-- <image src="../../static/inages/guanyu.png" class="icon"></image> -->
				</view>
				<view class="content" @click="getMe()" hover-class="none">
					<text class="icon-more text-green"></text>
					<text class="text-grey">关于我们</text>
				</view>
			</view>
		</view>
		<!-- <view class="cu-bar bg-white solid-bottom margin-top">
		        <view class='action'>
		                <text v-if="isShowUserName" class='icon-titles text-red margin-left-sm' bindtap="reload">退出登录</text> 
		                <view hover-class="tt"><text v-if="!isShowUserName" class='icon-titles text-black margin-left-sm'>关于我们</text></view>  
		        </view>
				
		</view> -->
	</view>
</template>

<script>
	import login from '@/common/login.js'
	import check from '@/common/check.js'
	export default {
		data() {
			return {
				nickname: '',
				portrait: '/static/image/defult-portrait.png',
				isCanPay: 0
			}
		},
		onShow() {
			login.getAuth(() => {
				this.setUserInfo()
			}, () => {
				this.setUserInfo()
			});
		},
		onLoad() {
			check.checkIsCanPay(data => {
				this.isCanPay = data
			})
		},
		methods: {
			setUserInfo() {
				this.nickname = uni.getStorageSync('nickname');
				this.portrait = uni.getStorageSync('portrait');
			},
			login() {
				login.login((res) => {
					this.setUserInfo(res.data)
				})
			},
			getMe() {
				uni.navigateTo({
					url: "/pages/me/me"
				})
			},
			toOrder() {
				login.getAuth(() => {
					this.setUserInfo()
					uni.navigateTo({
						url: '/pages/order/order'
					})
				}, () => {
					this.setUserInfo()
					uni.navigateTo({
						url: '/pages/order/order'
					})
				});
			}
		},
	}
</script>

<style>
	@import url("/static/css/me.css");

	.tt {
		background-color: #AAAAAA;
	}

	.icon {
		width: 40rpx;
		height: 40rpx;
		margin-right: 10rpx;
	}
</style>
